﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.TeamFoundation.Client;
using UCL.Powersource.TFS;

namespace Powersource.MockAppConnector
{
    public class TfsTeamProjectCollectionFactoryAdapter : ITfsTeamProjectCollectionFactory
    {
        private Dictionary<Uri, TfsTeamProjectCollectionAdapter> Cache;

        public ITfsTeamProjectCollection GetTeamProjectCollection(Uri uri)
        {
            if (Cache == null) Cache = new Dictionary<Uri, TfsTeamProjectCollectionAdapter>();

            if (!Cache.ContainsKey(uri))
            {
                var tfscol = new TfsTeamProjectCollectionAdapter(TfsTeamProjectCollectionFactory.GetTeamProjectCollection(uri));

                Cache.Add(uri, tfscol);
            }

            return Cache[uri];
        }
    }
}
